<template>
	<el-dialog :title="title" v-model="open" @close="open = false" append-to-body :close-on-click-modal="false" width="600px">
		<el-form :model="form" label-width="auto" disabled>
			<el-row :gutter="10" class="mb20">
				<el-col :span="12">
					<el-form-item label="审核状态">
						<el-input :modelValue="distributorWithdrawalStatusText(form.status)" />
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="申请时间">
						<el-input :modelValue="timeDictionary(form.apply_time)" />
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="10" class="mb20">
				<el-col v-if="form.status > 1" :span="12">
					<el-form-item label="审核时间">
						<el-input :modelValue="timeDictionary(form.check_time1)" />
					</el-form-item>
				</el-col>
				<el-col v-if="form.status == 3" :span="12">
					<el-form-item label="拒绝原因">
						<el-input :modelValue="form.cancel_reason" />
					</el-form-item>
				</el-col>
			</el-row>
			<el-row v-if="form.status == 2 || form.status > 3" :gutter="10" class="mb20">
				<el-col :span="12">
					<el-form-item label="打款状态">
						<el-input :modelValue="paymentStatusText(form.payment_status)" />
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="打款开始时间">
						<el-input :modelValue="timeDictionary(form.payment_start_time)" />
					</el-form-item>
				</el-col>
			</el-row>
			<el-row v-if="form.status > 3 || form.payment_fail_reason" :gutter="10" class="mb20">
				<el-col v-if="form.status > 3" :span="12">
					<el-form-item label="打款结束时间">
						<el-input :modelValue="timeDictionary(form.payment_notify_time)" />
					</el-form-item>
				</el-col>
				<el-col v-if="form.payment_fail_reason" :span="12">
					<el-form-item label="打款失败原因">
						<el-input :modelValue="form.payment_fail_reason" />
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
	</el-dialog>
</template>

<script lang="ts">
import { reactive, toRefs } from 'vue';
import { withdrawalSelectTime } from '/@/api/admin1';
import { distributorWithdrawalStatusText, paymentStatusText, timeDictionary } from '/@/utils/dictionaryTranslation';

export default {
	name: 'progressResultViewDialog',
	setup() {
		const state: any = reactive({
			title: '查看进度结果',
			open: false,
			form: {},
		});

		/********** 点击事件(on开头) **********/

		/********** 方法事件 **********/
		//打开
		const openDialog = (config: any) => {
			console.log(config);
			reset();
			state.open = true;
			_withdrawalSelectTime(config);
		};
		// 表单重置
		const reset = () => {
			state.form = {
				status: '',
				apply_time: '',
				check_time1: '',
				cancel_reason: '',
				payment_status: '',
				payment_start_time: '',
				payment_notify_time: '',
				payment_fail_reason: '',
			};
		};

		/********** 网络事件 **********/
		// 查看时间
		const _withdrawalSelectTime = (_data: any) => {
			withdrawalSelectTime(_data).then((res: any) => {
				console.log('查看时间', res);
				state.form = {
					...res.data.info,
					payment_fail_reason: _data.payment_fail_reason ? _data.payment_fail_reason : '',
				};
			});
		};

		return {
			openDialog,
			paymentStatusText,
			distributorWithdrawalStatusText,
			timeDictionary,
			...toRefs(state),
		};
	},
};
</script>

<style lang="scss" scoped></style>
